/* eslint-disable @typescript-eslint/no-misused-promises */
import { connectTencentNewsJSBridge } from '@tencent/gh-qqnews-sdk/gh-qqnews-jsapi';
if (/qqnews/i.test(navigator.userAgent)) {
  window.TencentNewsReady = connectTencentNewsJSBridge().then(() => window.TencentNews);
  window.ClientReady = window.TencentNewsReady;
} else if (/MicroMessenger/i.test(navigator.userAgent)) {
  window.WechatReady = new Promise((resolve) => {
    document.addEventListener('WeixinJSBridgeReady', () => {
      resolve(window.WeixinJSBridge);
    }, false);
  });
  window.ClientReady = window.WechatReady;
} else {
  window.ClientReady = new Promise((resolve) => {
    window.addEventListener('load', () => {
      resolve(undefined);
    });
  });
}
export const ClientReady = window.ClientReady as Promise<any>;
export const WechatReady = window.WechatReady as Promise<any> || new Promise(() => {});
export const TencentNewsReady = window.TencentNewsReady as Promise<any> || new Promise(() => {});
